<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8" />
        <title>选择登录方式-{eyou:global name='web_name' /}</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
        <link href="{eyou:global name='web_cmspath' /}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        {eyou:static file="users/skin/css/basic.css" /}
        {eyou:static file="users/skin/css/eyoucms.css" /}
        {eyou:include file="users/skin/css/diy_css.htm" /}
        {eyou:static file="/public/static/common/js/jquery.min.js"/}
        {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
        {eyou:static file="users/skin/js/global.js" /}
        {eyou:static file="/public/static/common/js/mobile_global.js" /}
    </head>

    <body class="login-reg">
        <div class="wrapper">
            <input type="hidden" id="wechat_url" value="{$eyou.field.wechat_url|default=''}">
            <div class="hend-box">
                <div class="title">登录</div>
                <div class="desc">还没有账号,<a href="{:url('user/Users/reg')}" style="color: #ff9600;">立即注册</a></div>
            </div>

            <div class="cont-box">
                <div id="con_sign_1">
                    <form action="" name='theForm' id="theForm" method="post" class="">
                        <div class="wx-form-group">
                            <input type="text" name="username" value="" required class="wx-form-control" placeholder="请输入账号" autocomplete="off" />
                        </div>
                        <div class="wx-form-group">
                            <input type="password" name="password" value="" required class="wx-form-control" placeholder="请输入密码" autocomplete="off" />
                            <span class="password-icon pass-showhide pass-hide" data-name="password"></span>
                        </div>
                        {eyou:eq name="$is_vertify" value="1"}
                        <div class="wx-form-group">
                            <div class="field">
                                <input type="text" name="vertify" autocomplete="off" class="wx-form-control" placeholder="请输入验证码" />
                                <img src="{eyou:url link='api/Ajax/vertify' vars='type=users_login' /}" class="chicuele" id="imgVerifys" onclick="handleVerifyRefresh('imgVerifys');" title="{:foreign_lang('users27')}" align="absmiddle">
                            </div>
                        </div>
                        {/eyou:eq}
                        <input type="hidden" name="referurl" value="{$referurl}" />
                        <input type="hidden" name="website" value="website" />
                        <input style="margin-top: 44px;" type="button" name="submit" class="btn btn-lg btn-primary btn-block" value="登录" />
                        <div class="login-link"> 
                            <a style="color: #ff9600;" id="click_sign_1" href="javascript:void(0);" onclick="showPhoneSignIn1();">使用手机号登录</a>
                        </div>
                    </form>
                </div>

                <div id="con_sign_2" style="display:none;">
                    <form action="" name='theMobileForm' id="theMobileForm" method="post" class="">
                        <div class="wx-form-group">
                            <input type="text" name="mobile" value="" required class="wx-form-control" placeholder="请输入手机号" autocomplete="off" />
                        </div>
                        <div class="wx-form-group" id="vertify_div">
                            <div class="field">
                                <input type="text" name="mobile_vertify" autocomplete="off" class="wx-form-control" placeholder="图片验证码" />
                                <img src="{eyou:url link='api/Ajax/vertify' vars='type=users_mobile_login' /}" class="chicuele" id="mobile_imgVerifys" onclick="mobile_fleshVerify();" title="{:foreign_lang('users27')}" align="absmiddle">
                            </div>
                        </div>
                        <div class="wx-form-group">
                            <div class="field">
                                <input id="mobile_code" type="text" class="wx-form-control" name="mobile_code" placeholder="请输入动态码">
                                <input type="button" id="mobile_code_button" onclick="send_mobile_code();" class="sento" value="获取动态码">
                            </div>
                        </div>
                        <input type="hidden" name="referurl" value="{$referurl}" />
                        <input type="hidden" name="website" value="website" />
                        <input type="hidden" name="__mobile_1_token__" value="{$Request.token.__mobile_1_token__}" />
                        <input style="margin-top: 44px;" type="button" onclick="checkMobileUserLogin1649732103()" class="btn btn-lg btn-primary btn-block" value="登录" />
                        <div class="login-link">
                            <a class="fr" style="color: #ff9600;" id="click_sign_2" href="javascript:void(0);" onclick="showPhoneSignIn2();">使用账号登录</a>
                        </div>
                        <script>
                            $("input[name=mobile]").keyup(function(event){
                                var mobile = $(this).val();
                                if (11 == mobile.length && 32 <= event.keyCode) {
                                    $('#vertify_div').css('display','block');
                                }
                            });
                            $("input[name=mobile_vertify]").keyup(function(event){
                                var mobile_vertify = $(this).val();
                                if (4 <= mobile_vertify.length && 32 <= event.keyCode) {
                                    send_mobile_code();
                                }
                            });
                                            
                            function send_mobile_code() {
                                var mobile = $("input[name=mobile]").val();
                                // 手机号是否为空
                                if (!mobile) {
                                    $("input[name=mobile]").focus();
                                    layer.msg(ey_foreign_users28, {time: 1500});
                                    return false;
                                }
                                            
                                // 手机格式不正确
                                var reg = /^1[0-9]{10}$/i;
                                if (!reg.test(mobile)) {
                                    $("input[name=mobile]").focus();
                                    layer.msg('请输入正确的请输入手机号码！', {time: 1500});
                                    return false;
                                }
                                $('#vertify_div').css('display','block');
                                var mobile_vertify = $("input[name=mobile_vertify]").val();
                                if (!mobile_vertify) {
                                    return false;
                                }
                                            
                                // 设置为不可点击
                                $("#mobile_code_button").val('获取中…').attr('disabled', 'disabled');
                                var __mobile_1_token__ = $('input[name=__mobile_1_token__]').val();
                                            
                                $.ajax({
                                    url: "{eyou:url link='api/Ajax/SendMobileCode' /}",
                                    // source:2 登录
                                    data: {type:'users_mobile_login', mobile:mobile, is_mobile:true, title:'登录', source:2,IsVertify:1, vertify:mobile_vertify, __mobile_1_token__:__mobile_1_token__},
                                    type:'post',
                                    dataType:'json',
                                    success:function(res){
                                        if (res.code == 1) {
                                            code_countdown();
                                            layer.msg(res.msg, {time: 1500});
                                        } else {
                                            $("#mobile_code_button").val('获取验证码').removeAttr("disabled");
                                            layer.alert(res.msg, {icon: 2, title: false, closeBtn: 0});
                                        }
                                    },
                                    error : function() {
                                        $("#mobile_code_button").val('获取验证码').removeAttr("disabled");
                                        layer.alert('发送失败，请尝试重新发送！', {icon: 5, title: false, closeBtn: 0});
                                    }
                                });
                            }

                            function mobile_fleshVerify() {
                                // 更新验证码
                                handleVerifyRefresh('mobile_imgVerifys', 'users_mobile_login');
                                // 更新token
                                $.ajax({
                                    async:false,
                                    url: "__ROOT_DIR__/index.php?m=api&c=Ajax&a=get_token&name=__mobile_1_token__",
                                    data: {_ajax:1},
                                    type:'GET',
                                    dataType:'html',
                                    success:function(res1){
                                        $('input[name=__mobile_1_token__]').val(res1);
                                    },
                                    error : function(e) {
                                        layer.closeAll();
                                        layer.alert(e.responseText, {icon: 5, title:false});
                                    }
                                });
                            }
                                            
                            function code_countdown(){
                                // 倒计时
                                var setTime;
                                var time = 120;
                                setTime = setInterval(function() {
                                    if(0 >= time) {
                                        clearInterval(setTime);
                                        return false;
                                    }
                                            
                                    time--;
                                    $("#mobile_code_button").val(time + '秒').attr('disabled', 'disabled');
                                    if(time == 0) $("#mobile_code_button").val('获取验证码').removeAttr("disabled");
                                }, 1000);
                            }
                            function checkMobileUserLogin1649732103() {
                                var mobile = $('#theMobileForm input[name=mobile]');
                                var mobile_code = $('#theMobileForm input[name=mobile_code]');
                                            
                                if (mobile.val() == '') {
                                    layer.msg('手机号不能为空！', {
                                        time: 1500
                                    });
                                    mobile.focus();
                                    return false;
                                }
                                            
                                if (mobile_code.val() == '') {
                                    layer.msg(ey_foreign_users30, {
                                        time: 1500
                                    });
                                    mobile_code.focus();
                                    return false;
                                }
                                            
                                layer_loading('正在处理');
                                $.ajax({
                                    url: "{eyou:url link='user/Users/mobile_login' /}",
                                    data: $('#theMobileForm').serialize(),
                                    type: 'post',
                                    dataType: 'json',
                                    success: function(res) {
                                        if (1 == res.code) {
                                            if (5 == res.data.status) {
                                                layer.alert(res.msg, {
                                                    icon: 5,
                                                    title: false,
                                                    closeBtn: false
                                                }, function() {
                                                    window.location.href = res.url;
                                                });
                                            } else {
                                                window.location.href = res.url;
                                            
                                            }
                                        } else {
                                            layer.closeAll();
                                            if ('vertify' == res.data.status) {
                                                mobile_fleshVerify();
                                            }
                                            
                                            if (2 == res.data.status) {
                                                showErrorAlert(res.msg, 4);
                                            } else {
                                                layer.msg(res.msg, {
                                                    icon: 5,
                                                    time: 1500
                                                });
                                            }
                                        }
                                    },
                                    error: function(e) {
                                        layer.closeAll();
                                        showErrorAlert(e.responseText);
                                    }
                                });
                            }
                        </script>
                    </form>
                </div>

                <!-- 第三方账号登录 -->
                {eyou:if condition="!empty($weapp_wxlogin) || !empty($weapp_qqlogin) || !empty($weapp_wblogin)"}
                <div class="account-login">
                    {eyou:notempty name="$weapp_qqlogin"}
                    <a href="{eyou:url link='plugins/QqLogin/login' seo_pseudo='1' seo_inlet='0' /}" class="qq-login"></a>
                    {/eyou:notempty}
                    {eyou:notempty name="$weapp_wxlogin"}
                    <a href="{eyou:url link='plugins/WxLogin/login' seo_pseudo='1' seo_inlet='0' /}" class="wechat-login"></a>
                    {/eyou:notempty}
                    {eyou:notempty name="$weapp_wblogin"}
                    <a href="{eyou:url link='plugins/Wblogin/login' seo_pseudo='1' seo_inlet='0' /}" class="weibo-login"></a>
                    {/eyou:notempty}
                </div>
                {/eyou:if}
                <!-- 第三方账号登录 -->
            </div>
        </div>
        {eyou:static file="users/skin/js/users_login.js" /}

        <script type="text/javascript">
            // 使用微信登录
            function wechat_login() {
                var wechat_url = $('#wechat_url').val();
                if (!wechat_url) {
                    showErrorAlert('网络失败，请刷新页面后重试');
                }
                layer_loading('正在处理');
                $.ajax({
                    url: wechat_url,
                    data: {data:0},
                    type: 'post',
                    dataType:'json',
                    success:function(res){
                        layer.closeAll();
                        if (res.code == 1) {
                            window.location.href = res.url;
                        } else {
                            layer.msg(res.msg, {time: 2000, icon: 5});
                        }
                    },
                    error : function(e) {
                        layer.closeAll();
                        showErrorAlert(e.responseText);
                    }
                });
            };

            $(function() {
                $('input[name=submit]').on('click', function() {
                    // 账号判断
                    var username = $('input[name=username]');
                    if (username.val() == '') {
                        username.focus();
                        showLayerMsg(ey_foreign_users16);
                        return false;
                    }
                    // 密码判断
                    var password = $('input[name=password]');
                    if (password.val() == '') {
                        password.focus();
                        showLayerMsg(ey_foreign_users18);
                        return false;
                    }
                    var formData = $('#theForm').serialize();
                    // 等保插件密码复杂判断，需在(formData)变量后面
                    {$pwdJsCode|default=''}

                    // 提交登录
                    showLayerLoad();
                    $.ajax({
                        url : eyou_basefile + "?m=user&c=Users&a=login",
                        data: formData,
                        type: 'post',
                        dataType: 'json',
                        success: function(res) {
                            if (1 == res.code) {
                                if (5 == res.data.status) {
                                    showLayerMsg(res.msg, 2, function() {
                                        window.location.href = res.url;
                                    });
                                } else {
                                    window.location.href = res.url;
                                }
                            } else {
                                layer.closeAll();
                                if (2 == res.data.status) {
                                    showLayerAlert(res.msg, 4);
                                } else {
                                    showLayerMsg(res.msg);
                                }
                                if ('vertify' == res.data.status) handleVerifyRefresh();
                            }
                        },
                        error: function(e) {
                            layer.closeAll();
                            showLayerAlert(e.responseText);
                        }
                    });
                });
            });
        </script>
    </body>
</html>